#ifndef SIP_DIALOGSET_HPP__
#define SIP_DIALOGSET_HPP__

#include "WTResipDll/SipWTResipDllItf.hpp"
#include "WTResipDll/SipDialog.hpp"

#include <deque>
#include <map>


namespace wtsip{

class CSipUserAgent;
class CSipInviteDialog;
class CSipRegistration;
class CSipSubscription;
class CSipDialogBase;
class CSipDlgTimeOut;
class CSipDlgAction;



class CSipDialogSet
{
public:

    CSipDialogSet(CSipUserAgent& ua);

    virtual ~CSipDialogSet();    

    virtual ISipDialogBase* createDialog(const SUri& local, const SUri& remote);

    virtual ISipDialogBase* createDialog(ISipSrvTransaction& srv, CSipMessage& msg);
    
    CSipDialogBase* matchDialog(const CSipDialogKey& id);

    CSipDialogBase* matchDialog(CSipMessage& msg);

    bool insertDialog(CSipDialogBase* dlg);

    bool destroyDialog(const CSipDialogKey& id);

    bool isDialogRequest(CSipMessage& msg);

    bool registerHandle(IDialogSetHandle* h);

    bool unregisterHandle(IDialogSetHandle* h);

    //bool postTimeOut(CSipDlgTimeOut& tOut, int seconds);

    //static bool toNameAddr(const Data& target, const Data& tUri, const int port, NameAddr& nAddr);

    CSipUserAgent& getUserAgent(){ return m_ua; }

private:

    std::map<CSipDialogKey, CSipDialogBase*> m_DialogsMap;

    //std::deque<const resip::Data*> m_shutdownFifo;

    //std::deque<CSipDlgAction*> m_DlgActions;

    //CSipDlgSetHandle* m_dlgSetHandle;

    CSipUserAgent& m_ua;

    IDialogSetHandle* m_handle;
};

}

#endif
